package com.ikaros.dto;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.ikaros.entity.OrderDetail;
import com.ikaros.enums.OrderStatusEnums;
import com.ikaros.enums.PayStatusEnums;
import com.ikaros.utils.EnumUtil;
import com.ikaros.utils.serializer.Date2LongSerializer;
import lombok.Data;

import javax.persistence.Id;
import javax.persistence.Transient;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.List;

/**
 * Created by Ikaros on 2017/9/25.
 * DTO数据传输对象
 */
@Data
//@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
//@JsonInclude(JsonInclude.Include.NON_NULL) //ps：这个注解可以使值为null的不返回成json eg.orderDetailList=null就不显示到页面
public class OrderDTO {

    /** 订单id. */
    private String orderId;

    /** 买家名字. */
    private String buyerName;

    /** 买家电话. */
    private String buyerPhone;

    /** 买家地址. */
    private String buyerAddress;

    /** 买家微信openid. */
    private String buyerOpenid;

    /** 订单总金额. */
    private BigDecimal orderAmount;

    /** 订单状态：默认新订单. */
    private Integer orderStatus;

    /** 支付状态：默认未支付. */
    private Integer payStatus;

    /** 创建时间. */
    @JsonSerialize(using = Date2LongSerializer.class)
    private Timestamp createTime;

    /** 更新时间. */
    @JsonSerialize(using = Date2LongSerializer.class)
    private Timestamp updateTime;

    private List<OrderDetail> orderDetailList;

    @JsonIgnore
    public OrderStatusEnums getOrderStatusEnums(){
        return EnumUtil.getByCode(orderStatus,OrderStatusEnums.class);
    }

    @JsonIgnore
    public PayStatusEnums getPayStatusEnums(){
        return EnumUtil.getByCode(orderStatus,PayStatusEnums.class);
    }
}
